<template>
    <div class="page">
        <!-- <div class="bank">
            <div class="lable">
               <div class="lableName">
                    到账银行卡
                </div> 
                <div class="card">
                    <p class="cardName">平安银行</p>
                    <p class="text">2小时内到账</p>
                </div>
            </div>
        </div> -->
        <div class="fromMsg">
            <span class="lableName">
                提现奖励金
            </span>
            <div class="lable">
                <input type="input" maxlength="19" placeholder="" v-model="fromdata.amount">
            </div>
            <div class="amt">
                <span>奖励金余额{{money}}元</span>
                <span class="allmoney" @click="allmoney">全部提现</span>
            </div>
            <div class="fromBox" @click="pullmoney">
                奖励金提现
            </div>
        </div>
    </div>
</template>


<script>
import { Toast, Cell, MessageBox } from "mint-ui";
import { userWithdrawal, getUserAmt } from "../../../methods/request.js";
export default {
    // 最顶部黑色栏
    data() {
        return {
            money: "",
            show: false,
            userinpmoney: "",
            fromdata:{
                amount:""
            }
        };
    },
    components: {},
    created() {
        this.$store.commit("increment", "提现");
        this.route = Object.assign({}, this.$route);
        this.getAmt();
    },
    methods: {
        getAmt() {
            this.$vux.loading.show({
                text: "Loading"
            });
            getUserAmt({})
                .then(response => {
                    this.$vux.loading.hide();
                    if (response.data.result == "0000") {
                        this.money = response.data.amt;
                    }
                })
                .catch(error => {
                    console.log(error);
                    this.$vux.loading.hide();
                });
        },
        checkNumber(num) {
            var reg = /^[0-9]+.?[0-9]*$/;
            if (reg.test(num)) {
                return true;
            }
            return false;
        },
        allmoney(){
            this.fromdata.amount = this.money;
        },
        pullmoney() {
            if (this.fromdata.amount == "" || !this.checkNumber(this.fromdata.amount)) {
                Toast({
                    message: "请填写正确的提现金额",
                    position: "middle",
                    duration: 3000
                });
                return false;
            }
            this.$vux.loading.show({
                text: "Loading"
            });
            userWithdrawal({ amount: this.fromdata.amount })
                .then(response => {
                    this.$vux.loading.hide();
                    if (response.rspCode == "0000") {
                        if (response.data.resCode == "0000") {
                            Toast({
                                message: "提现成功",
                                position: "middle",
                                duration: 3000
                            });
                            this.$router.push({
                                path: "/CashSucc",
                                query: {
                                    money: this.fromdata.amount
                                }
                            });
                        } else {
                            Toast({
                                message: response.data.message,
                                position: "middle",
                                duration: 3000
                            });
                        }
                    } else {
                        Toast({
                            message: "提现失败",
                            position: "middle",
                            duration: 3000
                        });
                    }
                    this.show = false;
                })
                .catch(error => {
                    console.log(error);
                    this.$vux.loading.hide();
                });
        }
    }
};
</script>
<style lang="less" scoped>
@import "~src/components/css/gloState.less";
.page {
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: #f1f2f3;
    overflow-x: auto;
}
.bank{
    width: 85%;
    margin: 10px auto;
    background: #ffffff;
    padding: 10px 15px;
    border-radius: 10px;
    position: relative; 
}
.fromMsg{
  width: 85%;
  margin: 20px auto;
  background: #ffffff;
  padding: 0 15px 54px;
  border-radius: 20px;
  position: relative;
}
.fromMsg .lable{
  font-size: 14px;
  border-bottom: 1px solid #ededed;
}
.fromMsg .lableName{
    float: left;
    display: block;
    padding: 10px 5px;
    font-size: 1.6rem;
}
.fromMsg .lable input{
  display: block;
  width: 100%;
  text-indent: 10px;
  height: 85px;
  outline:medium;
  font-size: 30px;
  border-bottom: 1px solid #dddddd;
}
.amt{
    display: block;
    width: 100%;
    color: #333333;
    text-align: left;
    line-height: 2.5rem;
    position: relative;
}
.allmoney{
    position: absolute;
    right: 1rem;
    top: 0rem;
    color: #ff3b2f;
}
.fromBox{
  position: absolute;
  left: 0;
  bottom: 0;
  height: 50px;
  line-height: 50px;
  color: #ffffff;
  background: #ff3b2f;
  width: 100%;
  border-radius: 0 0 20px 20px;
}
</style>
